package com.code8086.working;

public class WorkingDay
{
	public double[] point = new double[6];
	public double day_working_time;
	
	public static double max (double a, double b)
	{
		return a > b ? a : b;
	}
	
	public static double min (double a, double b)
	{
		return a < b ? a : b;
	}
	
	public double calWorkingTime ()
	{
		/* 补上上班时间 */
		/* 班段1 */
		if(point[0]+point[1]-0.1 > 0)
		{
			point[0] = max(point[0], 8.5);
			point[1] = point[1]-0.1 < 0 ? 12: min(point[1], 12);
		}
		/* 班段2 */
		if(point[2]+point[3]-0.1 > 0)
		{
			point[2] = max(point[2], 14.5);
			point[3] = point[3]-0.1 < 0 ? 18 : min(point[3], 18);
		}
		/* 班段3 */
		if(point[4]+point[5]-0.1 > 0)
		{
			point[4] = max(point[4], 19);
			point[5] = point[5]-0.1 < 0 ? 21.5 : min(point[5], 21.5);
		}
		double sum = 0.00;
		if (point[0] != 0.00 && point[1] != 0.00) sum += (point[1] - point[0]);
		if (point[2] != 0.00 && point[3] != 0.00) sum += (point[3] - point[2]);
		if (point[4] != 0.00 && point[5] != 0.00) sum += (point[5] - point[4]);
		return sum;
	}
}
